<?php

namespace app\admin\controller;

use app\common\controller\AdminBase;
use think\App;

use think\exception\ValidateException;
use think\facade\Log;

use think\facade\Db;
/**
 * Querypurchase控制器
 */
class Apierrorlog extends AdminBase
{

    protected $validate = null;

    protected $relationSearch = false;

    public function __construct(App $app)
    {
        parent::__construct($app);

        $this->validate = \app\admin\validate\Apierrorlog::class;
    }

    
    /**
     * 列表
     */
    public function index()
    {

        $data = [
            'code' => 1,
            'msg' => '',
            'count' =>0,
            'data' => [],
        ];

        return json($data);
    }
    /**
     * 修改
     *
     */
    public function edit()
    {
        $id= input('id');
        $row = $this->model->find($id);
        if (empty($row)) {
            return error('数据不存在');
        }

        if ($this->request->isPost()) {
            $post = $this->request->post();
            try {
                $this->validate && validate($this->validate)->check($post);
                $result = $row->save($post);
                if ($result) {
                    return success('保存成功！');
                }
                return error('保存失败');
            } catch (ValidateException $e) {

                return error($e->getError());
            } catch (\Exception $e) {
                Log::error("--------:" . $e);
                return error('保存失败');
            }
        }
        return success('ok', $row);
    }

}
